<?php

namespace app\admin\model;

use think\Model;


class Platcourse extends Model
{

    

    

    // 表名
    protected $name = 'learn_course';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'status_text',
        'is_buy_text',
        'is_chat_text'
    ];
    

    
    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1')];
    }

    public function getIsBuyList()
    {
        return ['0' => __('Is_buy 0'), '1' => __('Is_buy 1')];
    }

    public function getIsChatList()
    {
        return ['0' => __('Is_chat 0'), '1' => __('Is_chat 1')];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsBuyTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_buy']) ? $data['is_buy'] : '');
        $list = $this->getIsBuyList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsChatTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_chat']) ? $data['is_chat'] : '');
        $list = $this->getIsChatList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
